<?php ob_start(); 
session_start();
	include('../controller/functions.php');
	User::connection();

$userArr	= array('admin','teacher');
	if(!in_array($_SESSION['user'],$userArr)) {
	User::validSession();

}
if ($_GET['q'] == 'logout') 
{
	User::user_logout(); 
		print '		
			<script type="text/javascript">		
			window.location = "../login_r.php";
			</script>
			';

}
$user_id = $_SESSION['curuser'];
$page 	 = $_GET['page'];
$sec	 = $_GET['section'];


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="../images/fav.ico">
<link rel="icon" type="image/gif" href="../images/fav.ico">
<title>Create Question </title>

	<link rel="stylesheet" href="../css/style2.css" type="text/css" charset="utf-8" />
    <link rel="stylesheet" href="../css/front.css" type="text/css" charset="utf-8" />
    	<link type="text/css" href="../css/demo.css" rel="stylesheet" />
        <link rel="stylesheet" href="../css/general.css" type="text/css" charset="utf-8" />
</head>

						<script type="text/javascript">
				
					function checkform(upload_form){

					
								if (upload_form.math_question.value == "") {
								alert("Please enter a question.");
								upload_form.math_question.focus();
								return false ;
							}
	
						if (upload_form.math_choice1.value == "") {
								alert("Please enter choice A.");
								upload_form.math_choice1.focus();
								return false ;
							}
	
						if (upload_form.math_choice2.value == "") {
								alert("Please enter choice B.");
								upload_form.math_choice2.focus();
								return false ;
							}

							if (upload_form.math_choice3.value == "") {
								alert("Please enter choice C.");
								upload_form.math_choice3.focus();
								return false ;
							}
							
								if (upload_form.math_choice4.value == "") {
								alert("Please enter choice D.");
								upload_form.math_choice4.focus();
								return false ;
							}
					
	

						return true;
					}
					//-->
				</script>
<body>

 <div id="page">
<div id="wrapper">
        
        		   <div class="header_top" id="header_top"> </div>
  </div>
  <div class="header2"></div> 
	<div class="header"><!--open logo -->
		  </div><!--end header -->
	<!-- close logo-->
<!-- hide the client inquiries php-->
    <?php
    echo '<div id="nav">';
    echo '<div class="underlinemenu">';
	include('menu_view.php');
	echo '</div>';
    echo '</div>';
	?>
    <div id="header_in"> <!--open header -->
   <p> </p>
    
    <table width="100%" height="56">
     <tr>
       <td width="317" align="left" class="date"> 
        <? User::oras(); ?>
        </td>
            
       <td width="388" align="right"><? User::showPic(); ?></td>
       <td width="279">&nbsp;&nbsp;<? User::showUser(); ?>        </td>
       </tr>
   </table>
     
  
    </div>
    <div id="ex">
    </div>
    
      <p> </p>
       <div id="body"> <!--open body -->
    
	 <div id="sidebar"> 
      <!--  <div id="chef_ind"> open chef -->
        <div id="welcome"> <!--open welcome -->
         <!-- <h2 class="guilded"></h2> -->
        </div> <!--close welcome-->

<? echo '<p class="more">';
echo '';
 
   require('sideBar.php');
    
echo'</p>';
?>


        </div>
        
     <!-- </div>close left -->
      
      <div id="content"> 
      <div class="desriptionHeader"> <!--open right-->
       <div class="post"><!--open booking -->
          <div class="post3"> <h2>Add Question</h2> </div>
            <div class="desriptionHeader"> <!--open right-->
       <div class="post3"><!--open booking -->
<div align="center" class="mainbox">
<?php

	switch($page){

			
			/************************************************************
		*
		*		modify_pages.php?page=math
		*
		*************************************************************/
		case 'makabayan':
	
		$success=$_GET['success'];
		$sec	 = $_GET['section'];
	
	
		
				if(isset($_GET['add'])){
				$sec	 = $_POST['secName'];
				$math_question = addslashes($_POST['math_question']);
				$math_choice1 = addslashes($_POST['math_choice1']);
				$math_choice2 = addslashes($_POST['math_choice2']);
				$math_choice3 = addslashes($_POST['math_choice3']);
				$math_choice4 = addslashes($_POST['math_choice4']);			
				$math_answer = addslashes($_POST['math_answer']);	
				$tago = addslashes($_POST['tago']);			
				if(isset($_POST['add_submit'])){
					$sql = "INSERT INTO `tblexam`
						(questionDesc,questionAnswer,creatorId,sectionId,chooseA,chooseB,chooseC,chooseD,active,daytime,category)
							VALUES ('$math_question','$math_answer','$user_id','$sec','$math_choice1','$math_choice2','$math_choice3','$math_choice4','$tago',NOW(),'makabayan')";
					$result = mysql_query($sql);
					if($result){
						
			print'		<script type="text/javascript">
		
		alert("OK.");
		window.history.go(-2)

		</script>	';
					}
				
				}
				
			}	
	
echo'

		<form enctype="multipart/form-data" action="createQuestion.php?page=makabayan&add=1" method="POST" name="upload_form" onsubmit="return checkform(this);">
<table width="70%" border="0" style="background:#ffffff;border-color:#5c481a;border-width:1px;border-style:solid;">';

		
echo '<tr><td style="background-color:#1a2701;
color:#FFFFFF;
font-weight:bold;" colspan="2">MAKABAYAN</td>   
</tr>
<input name="sec"  type="hidden" value="'.$sec.'"/>
<tr><td><textarea cols="70" name="math_question">Type Question here</textarea></td></tr>';
echo '<tr><td>';

	$q	= 				"SELECT  s.sectionid, s.sectionName
												 FROM tblsection s WHERE s.studentName = 'none'
												  ;		
									";
									$select		= 	"<select id='secName' name='secName'>";	
									$select .= "<option value = 0 selected='selected' >Select Section</option>";		
									$temp 	= mysql_query($q);	
									while ($selName	= mysql_fetch_assoc($temp)) {		
										$secIDd = $selName['sectionid'];
										$n = $selName["sectionName"];
										$select .= "<option value = '".$secIDd."'>	".$n."</option>";
										
									}
									$select	   .= 	"</select>";
									
									$secAdvName	= $select;
									
									print($secAdvName);

echo '</tr></td>';
echo '
<tr><td>a)&nbsp;<input name="math_choice1"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="a">
</td></tr>
<tr><td>b)&nbsp;<input name="math_choice2"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="b">
</td></tr>
<tr><td>c)&nbsp;<input name="math_choice3"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="c">
</td></tr>
<tr><td>d)&nbsp;<input name="math_choice4"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="d">
</td></tr>			<td><select name="tago"><option value="1">show</option><option value="0">hide</option></select>
							<input type="submit" name="add_submit" value="Add"/>
							</td>';
echo "</table></form><br/><table><tr><td><font color='green'>$success</font></td></tr></table>";	
echo '<p>';
		echo '	<iframe id="blockrandom" name="iframe"	src="questionsMakabayan.php"
	
		scrolling="auto"
	width="100%"
	height="100%"
		 frameborder="0">'; 
	echo '</iframe>';


			break;		
		/************************************************************
		*
		*		modify_pages.php?page=science
		*
		*************************************************************/
		case 'science':
		
				$success=$_GET['success'];
		$sec	 = $_GET['section'];
	
	
		
				if(isset($_GET['add'])){
				$sec	 = $_POST['secName'];
				$math_question = addslashes($_POST['math_question']);
				$math_choice1 = addslashes($_POST['math_choice1']);
				$math_choice2 = addslashes($_POST['math_choice2']);
				$math_choice3 = addslashes($_POST['math_choice3']);
				$math_choice4 = addslashes($_POST['math_choice4']);			
				$math_answer = addslashes($_POST['math_answer']);	
				$tago = addslashes($_POST['tago']);			
				if(isset($_POST['add_submit'])){
					$sql = "INSERT INTO `tblexam`
						(questionDesc,questionAnswer,creatorId,sectionId,chooseA,chooseB,chooseC,chooseD,active,daytime,category)
							VALUES ('$math_question','$math_answer','$user_id','$sec','$math_choice1','$math_choice2','$math_choice3','$math_choice4','$tago',NOW(),'science')";
					$result = mysql_query($sql);
					if($result){
						
			print'		<script type="text/javascript">
		
		alert("OK.");
		window.history.go(-2)

		</script>	';
					}
				
				}
				
			}	
	
echo'

		<form enctype="multipart/form-data" action="createQuestion.php?page=science&add=1" method="POST" name="upload_form" onsubmit="return checkform(this);">
<table width="70%" border="0" style="background:#ffffff;border-color:#5c481a;border-width:1px;border-style:solid;">';

		
echo '<tr><td style="background-color:#1a2701;
color:#FFFFFF;
font-weight:bold;" colspan="2">SCIENCE</td>   
</tr>
<input name="sec"  type="hidden" value="'.$sec.'"/>
<tr><td><textarea cols="70" name="math_question">Type Question Here</textarea></td></tr>';
echo '<tr><td>';

	$q	= 				"SELECT  s.sectionid, s.sectionName
												 FROM tblsection s WHERE s.studentName = 'none'
												  ;		
									";
									$select		= 	"<select id='secName' name='secName'>";	
									$select .= "<option value = 0 selected='selected' >Select Section</option>";		
									$temp 	= mysql_query($q);	
									while ($selName	= mysql_fetch_assoc($temp)) {		
										$secIDd = $selName['sectionid'];
										$n = $selName["sectionName"];
										$select .= "<option value = '".$secIDd."'>	".$n."</option>";
										
									}
									$select	   .= 	"</select>";
									
									$secAdvName	= $select;
									
									print($secAdvName);

echo '</tr></td>';
echo '
<tr><td>a)&nbsp;<input name="math_choice1"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="a">
</td></tr>
<tr><td>b)&nbsp;<input name="math_choice2"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="b">
</td></tr>
<tr><td>c)&nbsp;<input name="math_choice3"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="c">
</td></tr>
<tr><td>d)&nbsp;<input name="math_choice4"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="d">
</td></tr>			<td><select name="tago"><option value="1">show</option><option value="0">hide</option></select>
							<input type="submit" name="add_submit" value="Add"/>
							</td>';
echo "</table></form><br/><table><tr><td><font color='green'>$success</font></td></tr></table>";	
echo '<p>';
		echo '	<iframe id="blockrandom" name="iframe"	src="questionsScience.php"
	
		scrolling="auto"
	width="100%"
	height="100%"
		 frameborder="0">'; 
	echo '</iframe>';

			break;
		/************************************************************
		*
		*		modify_pages.php?page=english
		*
		*************************************************************/
		case 'english':
		$success=$_GET['success'];
		$sec	 = $_GET['section'];
	
	
		
				if(isset($_GET['add'])){
				$sec	 = $_POST['secName'];
				$math_question = addslashes($_POST['math_question']);
				$math_choice1 = addslashes($_POST['math_choice1']);
				$math_choice2 = addslashes($_POST['math_choice2']);
				$math_choice3 = addslashes($_POST['math_choice3']);
				$math_choice4 = addslashes($_POST['math_choice4']);			
				$math_answer = addslashes($_POST['math_answer']);	
				$tago = addslashes($_POST['tago']);			
				if(isset($_POST['add_submit'])){
					$sql = "INSERT INTO `tblexam`
						(questionDesc,questionAnswer,creatorId,sectionId,chooseA,chooseB,chooseC,chooseD,active,daytime,category)
							VALUES ('$math_question','$math_answer','$user_id','$sec','$math_choice1','$math_choice2','$math_choice3','$math_choice4','$tago',NOW(),'english')";
					$result = mysql_query($sql);
					if($result){
						
			print'		<script type="text/javascript">
		
		alert("OK.");
		window.history.go(-2)

		</script>	';
					}
				
				}
				
			}	
	
echo'

		<form enctype="multipart/form-data" action="createQuestion.php?page=english&add=1" method="POST" name="upload_form" onsubmit="return checkform(this);">
<table width="70%" border="0" style="background:#ffffff;border-color:#5c481a;border-width:1px;border-style:solid;">';

		
echo '<tr><td style="background-color:#1a2701;
color:#FFFFFF;
font-weight:bold;" colspan="2">ENGLISH</td>   
</tr>
<input name="sec"  type="hidden" value="'.$sec.'"/>
<tr><td><textarea cols="70" name="math_question">Type Question here</textarea></td></tr>';
echo '<tr><td>';

	$q	= 				"SELECT  s.sectionid, s.sectionName
												 FROM tblsection s WHERE s.studentName = 'none'
												  ;		
									";
									$select		= 	"<select id='secName' name='secName'>";	
									$select .= "<option value = 0 selected='selected' >Select Section</option>";		
									$temp 	= mysql_query($q);	
									while ($selName	= mysql_fetch_assoc($temp)) {		
										$secIDd = $selName['sectionid'];
										$n = $selName["sectionName"];
										$select .= "<option value = '".$secIDd."'>	".$n."</option>";
										
									}
									$select	   .= 	"</select>";
									
									$secAdvName	= $select;
									
									print($secAdvName);

echo '</tr></td>';
echo '
<tr><td>a)&nbsp;<input name="math_choice1"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="a">
</td></tr>
<tr><td>b)&nbsp;<input name="math_choice2"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="b">
</td></tr>
<tr><td>c)&nbsp;<input name="math_choice3"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="c">
</td></tr>
<tr><td>d)&nbsp;<input name="math_choice4"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="d">
</td></tr>			<td><select name="tago"><option value="1">show</option><option value="0">hide</option></select>
							<input type="submit" name="add_submit" value="Add"/>
							</td>';
echo "</table></form><br/><table><tr><td><font color='green'>$success</font></td></tr></table>";	
echo '<p>';
		echo '	<iframe id="blockrandom" name="iframe"	src="questionsEnglish.php"
	
		scrolling="auto"
	width="100%"
	height="100%"
		 frameborder="0">'; 
	echo '</iframe>';

			break;
	
	
		case 'filipino':
		$success=$_GET['success'];
		$sec	 = $_GET['section'];
	
	
		
				if(isset($_GET['add'])){
				$sec	 = $_POST['secName'];
				$math_question = addslashes($_POST['math_question']);
				$math_choice1 = addslashes($_POST['math_choice1']);
				$math_choice2 = addslashes($_POST['math_choice2']);
				$math_choice3 = addslashes($_POST['math_choice3']);
				$math_choice4 = addslashes($_POST['math_choice4']);			
				$math_answer = addslashes($_POST['math_answer']);	
				$tago = addslashes($_POST['tago']);			
				if(isset($_POST['add_submit'])){
					$sql = "INSERT INTO `tblexam`
						(questionDesc,questionAnswer,creatorId,sectionId,chooseA,chooseB,chooseC,chooseD,active,daytime,category)
							VALUES ('$math_question','$math_answer','$user_id','$sec','$math_choice1','$math_choice2','$math_choice3','$math_choice4','$tago',NOW(),'filipino')";
					$result = mysql_query($sql);
					if($result){
						
			print'		<script type="text/javascript">
		
		alert("OK.");
		window.history.go(-2)

		</script>	';
					}
				
				}
				
			}	
	
echo'

		<form enctype="multipart/form-data" action="createQuestion.php?page=filipino&add=1" method="POST" name="upload_form" onsubmit="return checkform(this);">
<table width="70%" border="0" style="background:#ffffff;border-color:#5c481a;border-width:1px;border-style:solid;">';

		
echo '<tr><td style="background-color:#1a2701;
color:#FFFFFF;
font-weight:bold;" colspan="2">FILIPINO</td>   
</tr>
<input name="sec"  type="hidden" value="'.$sec.'"/>
<tr><td><textarea cols="70" name="math_question">Type Question here</textarea></td></tr>';
echo '<tr><td>';

	$q	= 				"SELECT  s.sectionid, s.sectionName
												 FROM tblsection s WHERE s.studentName = 'none'
												  ;		
									";
									$select		= 	"<select id='secName' name='secName'>";	
									$select .= "<option value = 0 selected='selected' >Select Section</option>";		
									$temp 	= mysql_query($q);	
									while ($selName	= mysql_fetch_assoc($temp)) {		
										$secIDd = $selName['sectionid'];
										$n = $selName["sectionName"];
										$select .= "<option value = '".$secIDd."'>	".$n."</option>";
										
									}
									$select	   .= 	"</select>";
									
									$secAdvName	= $select;
									
									print($secAdvName);

echo '</tr></td>';
echo '
<tr><td>a)&nbsp;<input name="math_choice1"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="a">
</td></tr>
<tr><td>b)&nbsp;<input name="math_choice2"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="b">
</td></tr>
<tr><td>c)&nbsp;<input name="math_choice3"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="c">
</td></tr>
<tr><td>d)&nbsp;<input name="math_choice4"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="d">
</td></tr>			<td><select name="tago"><option value="1">show</option><option value="0">hide</option></select>
							<input type="submit" name="add_submit" value="Add"/>
							</td>';
echo "</table></form><br/><table><tr><td><font color='green'>$success</font></td></tr></table>";	
echo '<p>';
		echo '	<iframe id="blockrandom" name="iframe"	src="questionsFilipino.php"
	
		scrolling="auto"
	width="100%"
	height="100%"
		 frameborder="0">'; 
	echo '</iframe>';
			break;
			
					case 'math':
	$success=$_GET['success'];
		$sec	 = $_GET['section'];
	
	
		
				if(isset($_GET['add'])){
				$sec	 = $_POST['secName'];
				$math_question = addslashes($_POST['math_question']);
				$math_choice1 = addslashes($_POST['math_choice1']);
				$math_choice2 = addslashes($_POST['math_choice2']);
				$math_choice3 = addslashes($_POST['math_choice3']);
				$math_choice4 = addslashes($_POST['math_choice4']);			
				$math_answer = addslashes($_POST['math_answer']);	
				$tago = addslashes($_POST['tago']);			
				if(isset($_POST['add_submit'])){
					$sql = "INSERT INTO `tblexam`
						(questionDesc,questionAnswer,creatorId,sectionId,chooseA,chooseB,chooseC,chooseD,active,daytime,category)
							VALUES ('$math_question','$math_answer','$user_id','$sec','$math_choice1','$math_choice2','$math_choice3','$math_choice4','$tago',NOW(),'math')";
					$result = mysql_query($sql);
					if($result){
						
			print'		<script type="text/javascript">
		
		alert("OK.");
		window.history.go(-2)

		</script>	';
					}
				
				}
				
			}	
	
echo'

		<form enctype="multipart/form-data" action="createQuestion.php?page=math&add=1" method="POST" name="upload_form" onsubmit="return checkform(this);">
<table width="70%" border="0" style="background:#ffffff;border-color:#5c481a;border-width:1px;border-style:solid;">';

		
echo '<tr><td style="background-color:#1a2701;
color:#FFFFFF;
font-weight:bold;" colspan="2">MATH</td>   
</tr>
<input name="sec"  type="hidden" value="'.$sec.'"/>
<tr><td><textarea cols="70" name="math_question">Type Question here</textarea></td></tr>';
echo '<tr><td>';

	$q	= 				"SELECT  s.sectionid, s.sectionName
												 FROM tblsection s WHERE s.studentName = 'none'
												  ;		
									";
									$select		= 	"<select id='secName' name='secName'>";	
									$select .= "<option value = 0 selected='selected' >Select Section</option>";		
									$temp 	= mysql_query($q);	
									while ($selName	= mysql_fetch_assoc($temp)) {		
										$secIDd = $selName['sectionid'];
										$n = $selName["sectionName"];
										$select .= "<option value = '".$secIDd."'>	".$n."</option>";
										
									}
									$select	   .= 	"</select>";
									
									$secAdvName	= $select;
									
									print($secAdvName);

echo '</tr></td>';
echo '
<tr><td>a)&nbsp;<input name="math_choice1"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="a">
</td></tr>
<tr><td>b)&nbsp;<input name="math_choice2"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="b">
</td></tr>
<tr><td>c)&nbsp;<input name="math_choice3"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="c">
</td></tr>
<tr><td>d)&nbsp;<input name="math_choice4"  type="text"/>&nbsp;<INPUT TYPE=RADIO NAME="math_answer" VALUE="d">
</td></tr>			<td><select name="tago"><option value="1">show</option><option value="0">hide</option></select>
							<input type="submit" name="add_submit" value="Add"/>
							</td>';
echo "</table></form><br/><table><tr><td><font color='green'>$success</font></td></tr></table>";	
echo '<p>';
		echo '	<iframe id="blockrandom" name="iframe"	src="questionsMath.php"
	
		scrolling="auto"
	width="100%"
	height="100%"
		 frameborder="0">'; 
	echo '</iframe>';
			break;
}
	ob_end_flush();
	?>
</div>
  </div><!--close booking -->
   </div><!--close desc -->
   
          
     				
	  </div><!--close booking -->
   </div><!--close desc -->
    	</div> <!--close right-->
      <div class="clear">&nbsp;</div>
 <!-- footer-->
 <?php 
	  echo '<div id="footer">';
     include('footer_view.php');
      echo '</div>';	
	  ?>

    </div><!-- close body-->
</div><!-- close page-->


</body>
</html>
